﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ChuanYe.CountyFireManagement.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ChuanYe.CountyFireManagement.Api.Models;

namespace ChuanYe.CountyFireManagement.Api.Controllers
{
    /// <summary>
    /// 站点
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LocaInfoController : ControllerBase
    {
        /// <summary>
        /// 分页   
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultDto<dynamic,dynamic> GetLocaInfoByPage(LocaInfoSearchRequest obj)
        {
            ResultDto<dynamic, dynamic> result = new ResultDto<dynamic, dynamic>();
            try
            {
                var page = Pickout.SetPage(obj);
                return BLL.LocaInfoBLL.Instance.GetLocaInfoByPage(obj.AddressCounty,page);
            }
            catch (Exception ex)
            {
                result.Status = 500;
                result.Message = "/LocaInfo/GetLocaInfoByPage Error";
                LogHelper.Error(result.Message,ex);
            }
            return result;
        }

        /// <summary>
        ///  根据 区域 获取 站点树型结构
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultDto<dynamic> GetLocaInfoByTree(LocaInfoSearchRequest2 obj) 
        {
            ResultDto<dynamic> result = new ResultDto<dynamic>();
            try
            {
                return BLL.LocaInfoBLL.Instance.GetLocaInfoByTree(obj.AddressCounty);
            }
            catch (Exception ex)
            {
                result.Status = 500;
                result.Message = "/LocaInfo/GetLocaInfoByTree Error";
                LogHelper.Error(result.Message,ex);
            }
            return result;
        }
    }
}